﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using VisualAgile.Model;
using System.Web.Security;

namespace VisualAgile.Web.Tests
{
    class FakeUserData
    {
        public static List<User> CreateTestUsers()
        {
            Guid userId = new Guid("2EBDBC36-3585-47b3-8709-BE3184956938");

            List<User> users = new List<User>()
            {
                DefaultUser(),
                AuthenticatedUser()
            };

            for (int i = 0; i < 10; i++)
            {
                User sampleUser = new User()
                {
                    UserID = userId,
                    CreateTime = DateTime.Now,                                        
                    Email = "user@user.com",
                    Mobile = "9886803882",
                    Password = EncryptPassword("goodPass"),                    
                    UserName = "someUser"                    
                };

                sampleUser.Role = Role.Developer;
                sampleUser.Project = FakeProjectData.SomeProject();                
                users.Add(sampleUser);
                userId = Guid.NewGuid();
            }
            
            return users;
        }

        public static string EncryptPassword(string password)
        {
            return FormsAuthentication.HashPasswordForStoringInConfigFile(password, "SHA1");
        }


        public static User DefaultUser()
        {
            User Default = new User()
            {
                UserID = new Guid("29DC7A46-52B5-4941-AAE2-F48592847E42"),
                CreateTime = DateTime.Now,
                Email = "default@demo.com",
                Mobile = "9886803882",                
                UserName = "default"
            };

            Default.Role = Role.LeadDeveloper;
            Default.Project = FakeProjectData.DemoProject();

            return Default;
        }

        public static User AuthenticatedUser()
        {
            User Default = new User()
            {
                UserID = new Guid("BE4B0656-8685-439e-B4EA-66D5C9BA7508"),
                CreateTime = DateTime.Now,
                Email = "default@demo.com",
                Mobile = "9886803882",
                Password = EncryptPassword("goodPass"),
                UserName = "default"
            };

            Default.Role = Role.Administrator;
            Default.Project = FakeProjectData.DefaultProject();

            return Default;
        }

        public static User Developer()
        {
            User Default = new User()
            {
                UserID = new Guid("47B01645-7C1E-4394-B6FD-E30D95D13F47"),
                CreateTime = DateTime.Now,
                Email = "default@demo.com",
                Mobile = "9886803882",                
                UserName = "dev"
            };

            Default.Role = Role.Developer;
            Default.Project = FakeProjectData.SomeProject();

            return Default;
        }       
    }
}
